home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
X User Tools
/
X User Tools (O'Reilly and Associates)(1994).ISO
/
sun4c
/
archive
/
tcltk.z
/
tcltk
/
man
/
cat3
/
DetachPids.3
< prev
next >
Wrap
Text File
|
1994-09-20
|
3KB
|
133 lines
Tcl_DetachPids(3) Tcl Library Procedures
_________________________________________________________________
NAME
Tcl_DetachPids, Tcl_ReapDetachedProcs - manage child
processes in background
SYNOPSIS
#include <tcl.h>
Tcl_DetachPids(_n_u_m_P_i_d_s, _p_i_d_P_t_r)
Tcl_ReapDetachedProcs() |
ARGUMENTS
int _n_u_m_P_i_d_s (in) Number of process ids contained
in the array pointed to by
_p_i_d_P_t_r.
int *_p_i_d_P_t_r (in) Address of array containing
_n_u_m_P_i_d_s process ids.
_________________________________________________________________
DESCRIPTION
Tcl_DetachPids and Tcl_ReapDetachedProcs provide a mechanism |
for managing subprocesses that are running in background. |
These procedures are needed because the parent of a process |
must eventually invoke the waitpid kernel call (or one of a |
few other similar kernel calls) to wait for the child to |
exit. Until the parent waits for the child, the child's |
state cannot be completely reclaimed by the system. If a |
parent continually creates children and doesn't wait on |
them, the system's process table will eventually overflow, |
even if all the children have exited. |
Tcl_DetachPids may be called to ask Tcl to take responsibil- |
ity for one or more processes whose process ids are con- |
tained in the _p_i_d_P_t_r array passed as argument. The caller |
presumably has started these processes running in background |
and doesn't want to have to deal with them again. |
Tcl_ReapDetachedProcs invokes the waitpid kernel call on |
each of the background processes so that its state can be |
cleaned up if it has exited. If the process hasn't exited |
yet, Tcl_ReapDetachedProcs doesn't wait for it to exit; it |
will check again the next time it is invoked. Tcl automati- |
cally calls Tcl_ReapDetachedProcs each time the exec command |
is executed, so in most cases it isn't necessary for any |
code outside of Tcl to invoke Tcl_ReapDetachedProcs. How- |
ever, if you call Tcl_DetachPids in situations where the |
exec command may never get executed, you may wish to call |
Tcl_ReapDetachedProcs from time to time so that background |
Tcl 1
Tcl_DetachPids(3) Tcl Library Procedures
processes can be cleaned up.
KEYWORDS
background, child, detach, process, wait
Tcl 2